import java.io.IOException;
import java.util.Arrays;
import java.util.Random;

import algorithms.HeapSorter;

public class MainClass {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int n = 1000;
		if( args.length > 1 )
		{
			try{
				n = Integer.parseInt(args[1]);
			}catch(Exception ex){
				
			}
		}
		Integer[] array = new Integer[n];
		Random rand = new Random(System.currentTimeMillis());
		for( int i = 0; i < array.length; i++ ){
			array[i] = rand.nextInt();
		}
		System.out.println(Arrays.toString(array));
		System.out.println("\nStart: "+System.currentTimeMillis());
		HeapSorter.sort(array);
		System.out.println("\nEnd: "+System.currentTimeMillis());
		System.out.println(Arrays.toString(array));
	}

}
